<?php
include "conn.php";
$art = showAllOfBlog(0);
$thead = ['标题', '发布时间', '作者'];
?>
<!doctype html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Blog</title>
</head>
<body>

<header>
    <ul class="nav">
        <li><a href="index.php" target="_self">首页</a></li>
        <li><a href="writeBlog.html" target="_self">写博客</a></li>
        <li><a href="manageBlog.php" target="_self">管理博客</a></li>
    </ul>
</header>
<main>
    <!--    <div class="pageDiv-container">-->
    <!--        <form class="pageDiv" method="get" action="index.php">-->
    <!--            <label for="pageCount">跳转页数</label>-->
    <!--            <input type="text" id="pageCount" class="pageCount">-->
    <!--            <input type="submit" value="Go">-->
    <!--        </form>-->
    <!--    </div>-->
    <div class="table-container">
        <table>
            <thead>
            <tr>
                <?php foreach ($thead as $item): ?>
                    <th><?php echo $item; ?></th>
                <?php endforeach; ?>
            </tr>
            </thead>
            <tbody>
            <?php foreach ($art as $item): ?>
                <tr>
                    <?php $id = $item['id_blog'] ?>
                    <td>
                        <a href="showBlog.php?id=<?php echo $id ?>" target="_self"><?php echo $item['title'] ?></a>
                    </td>
                    <td class="publish-td"><?php echo $item['publish'] ?></td>
                    <td class="author-td"><?php echo $item['author'] ?></td>
                </tr>
            <?php endforeach; ?>
            </tbody>
        </table>
    </div>
</main>
</body>
</html>


<style>
    header {
        background-color: aqua;
        height: 50px;
    }

    .nav {
        height: 100%;
        display: flex;
        padding: 0 20%;
    }

    .nav li {
        margin: 2px;
        list-style: none;
        width: 33%;
        align-items: center;
        display: flex;
        background-color: azure;
        justify-content: center;
    }

    .nav li a {
        text-decoration: none;
    }

    /*.pageDiv-container {*/
    /*    display: flex;*/
    /*    justify-content: center;*/
    /*}*/

    .table-container {
        display: flex;
        margin-top: 5px;
        justify-content: center;
        border: deeppink solid 2px;
    }

    table {
        width: 540px;
        margin-top: 5px;
        border: red solid 2px;
    }

    thead {
        font-weight: bold;
        border: deeppink solid 2px;
    }

    .publish-td {
        text-align: center;
    }

    .author-td {
        text-align: center;
    }

    /*.pageCount {*/
    /*    margin-right: 50px;*/
    /*}*/
</style>